# 客户端执行程序
from package.ThreadClient import ThreadClient
import Comment
import time
import os

conf = {
    'mainMod': 'Alipay',
    'shotFile': r'G:/python-control-phone/img/tmp.jpg'  #截图存放地
}
# 是否开锁 1为开锁
openLock = 0


# 上滑屏幕并解锁L形
def myLock():
    os.system('adb shell input swipe 500 700 500 50')
    time.sleep(1)
    os.system(
        'adb shell sendevent /dev/input/event2 0003 0057 00008780 &adb shell sendevent /dev/input/event2 0001 0330 00000001 &adb shell sendevent /dev/input/event2 0003 0053 00000566 &adb shell sendevent /dev/input/event2 0003 0054 00001007 &adb shell sendevent /dev/input/event2 0003 0048 00000004 &adb shell sendevent /dev/input/event2 0000 0000 00000000 &adb shell sendevent /dev/input/event2 0003 0053 00000525 &adb shell sendevent /dev/input/event2 0003 0054 00001616 &adb shell sendevent /dev/input/event2 0003 0048 00000006 &adb shell sendevent /dev/input/event2 0000 0000 00000000 &adb shell sendevent /dev/input/event2 0003 0053 00000915 &adb shell sendevent /dev/input/event2 0003 0054 00001545 &adb shell sendevent /dev/input/event2 0003 0048 00000005 &adb shell sendevent /dev/input/event2 0000 0000 00000000 &adb shell sendevent /dev/input/event2 0003 0057 4294967295 &adb shell sendevent /dev/input/event2 0000 0000 00000000')


# 初始化手机
def initPhone():
    # 检测手机是否灭屏
    wake = Comment.wakePhone()
    if (wake == 1):
        Comment.home()
    lock = Comment.isLock()
    if (lock == 1):
        myLock()


def startClient():
    if openLock:
        initPhone()
    ThreadClient(conf)


if __name__ == '__main__':
    startClient()
